﻿using System;
using System.Web;
using System.Web.UI;
using BusinessLogic.BusinessRules;
using Common;

namespace RichECMS.ServerPages
{
    public partial class CenterMain : Util.BasePage.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (State.LoginUser.ManagerCompetence < (int)Utility.ManagerCompetence.Admin)
            {
                ATemplateManager.Visible = true;
                ASectionManager.Visible = true;
                AJSManager.Visible = true;
                LiteralUserManager.Text = "<li><a href='User/UserManage.aspx' title='后台用户设置（权限）'>后台用户设置（权限）</a></li>";
            }
            else if (State.LoginUser.ManagerCompetence == (int)Utility.ManagerCompetence.Admin)
            {
                ATemplateManager.Visible = false;
                ASectionManager.Visible = true;
                AJSManager.Visible = false;
                LiteralUserManager.Text = "<li><a href='User/UserManage.aspx' title='后台用户设置（权限）'>后台用户设置（权限）</a></li>";
            }
            else if (State.LoginUser.ManagerCompetence == (int)Utility.ManagerCompetence.UserCanIssueAndClients)
            {
                ATemplateManager.Visible = false;
                ASectionManager.Visible = false;
                AJSManager.Visible = false;
                LiteralUserManager.Text = "<li><a href='User/UserManage.aspx' title='后台用户设置（权限）'>后台用户设置（权限）</a></li>";
            }
            else if (State.LoginUser.ManagerCompetence == (int)Utility.ManagerCompetence.UserCanIssue)
            {
                ATemplateManager.Visible = false;
                ASectionManager.Visible = false;
                AJSManager.Visible = false;
                LiteralUserManager.Text = "";
            }
            else if (State.LoginUser.ManagerCompetence > (int)Utility.ManagerCompetence.UserCanIssueAndClients)
            {
                ATemplateManager.Visible = false;
                ASectionManager.Visible = false;
                AJSManager.Visible = false;
                LiteralUserManager.Text = "";
            }


            if (!Page.IsPostBack)
            {
                LitUserName.Text = State.LoginUser.StrName;
                if (State.LoginUser.DtmLastAccessTime.ToString() != "0001-1-1 0:00:00")
                {
                    LitLastLoginTime.Text = State.LoginUser.DtmLastAccessTime.ToString("yyyy年MM月dd日 HH:mm");
                }
                else
                {
                    LitLastLoginTime.Text ="无";
                }
            }
        }
    }
}